package com.hackerrank.challenges.changingbits;

import java.util.BitSet;
import java.util.Scanner;

public class Solution {
	private static final String SET_A = "set_a", SET_B = "set_b", GET_C = "get_c";
	private static BitSet getBitSet(char[] a) {
		BitSet r = new BitSet(a.length);
		for(int i = 0; i < a.length; i++)
			if(a[i] == '1')
				r.set(a.length - i - 1);
		return r;
	}
	private static BitSet add(BitSet A, BitSet B) {
		int N = Math.max(A.length(), B.length());
		BitSet C = new BitSet(N + 1);
		int c = 0;
		for(int i = 0; i < N; i++) {
			int ai = A.get(i) ? 1 : 0, bi = B.get(i) ? 1 : 0, s = ai + bi + c;
			if(s % 2 == 1)
				C.set(i);
			c = s / 2;
		}
		if(c == 1)
			C.set(N);
		return C;
	}
	private static void increase(BitSet C, int ci) {
		while(C.get(ci))
			C.clear(ci++);
		C.set(ci);
	}
	private static void decrease(BitSet C, int ci) {
		while(!C.get(ci))
			C.set(ci++);
		C.clear(ci);
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), Q = in.nextInt();
		in.nextLine();
		char a[] = in.nextLine().trim().toCharArray(), b[] = in.nextLine().trim().toCharArray();
		BitSet A = getBitSet(a), B = getBitSet(b), C = add(A, B);
		for(int i = 0; i < Q; i++) {
			String w[] = in.nextLine().split(" ");
			if(w[0].equals(SET_A)) {
				int ai = Integer.parseInt(w[1]), v = Integer.parseInt(w[2]);
				if(v == 0 && A.get(ai)) {
					A.clear(ai);
					decrease(C, ai);
				} else if(v == 1 && !A.get(ai)) {
					A.set(ai);
					increase(C, ai);
				}
			} else if(w[0].equals(SET_B)) {
				int bi = Integer.parseInt(w[1]), v = Integer.parseInt(w[2]);
				if(v == 0 && B.get(bi)) {
					B.clear(bi);
					decrease(C, bi);
				} else if(v == 1 && !B.get(bi)) {
					B.set(bi);
					increase(C, bi);
				}
			} else {
				int ci = Integer.parseInt(w[1]);
				if(C.get(ci))
					System.out.print(1);
				else
					System.out.print(0);
			}
		}
	}
}
